package argirithm;

import java.util.Arrays;

/**统计每个英文大写字符出现的个数, 找出最多的前10个字符*/
public class Demo05 {
    public static void main(String[] args) {
//        int[][] counter = {{'A',0},{'B',0},{'C',0},{'D',0},
//                {'E',0},{'F',0},{'G',0},{'H',0},{'I',0},
//                {'J',0},{'K',0},{'L',0},{'M',0},{'N',0},
//                {'O',0},{'P',0},{'Q',0},{'R',0},{'S',0},
//                {'T',0},{'U',0},{'V',0},{'W',0},{'X',0},
//                {'Y',0},{'Z',0}};
        int [][] counter = new int[26][2];
        for (char c ='A' ;  c<='Z' ; c++) {
            counter[c-'A'][0] = c;
        }
        String str = "ASDCASDWQDASDASDFFSDFDCASCXXXX";
        for (int i = 0; i <str.length() ; i++) {
            char c = str.charAt(i);
            if (c>='A' && c<='Z'){
                counter[c-'A'][1]++;
            }
        }
        Arrays.sort(counter,(arr1,arr2)->arr2[1]-arr1[1]);
        for (int[] arr:counter) {
            System.out.println((char)(arr[0])+":"+arr[1]);
        }
    }
}
